//
//  NewCell.m
//  FiveWork
//
//  Created by lanou3g on 15/11/18.
//  Copyright © 2015年 Project. All rights reserved.
//

#import "NewCell.h"
#import "NewManger.h"
#import "NewModel.h"
#import "UIImageView+WebCache.h"

@interface NewCell ()
@property (nonatomic,strong)UIImageView *oneImageView;
@property (nonatomic,strong)UILabel*titleLabel;
@property(nonatomic,strong)UILabel *digestlabel;
@property(nonatomic,strong)UILabel *ptime;

@end
@implementation NewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubViews];
    }
    return self;
}

-(void)setupSubViews{
    
    CGFloat seX =130;
    CGFloat seY =5;
    CGFloat seW =235;
    CGFloat seH =30;
    self.titleLabel =[[UILabel alloc] initWithFrame:CGRectMake(seX, seY , seW, seH)];
    [self.contentView addSubview:self.titleLabel];
    
    CGFloat digX=seX;
    CGFloat digY =40;
    CGFloat digW =250;
    CGFloat digH =seH ;
    self.digestlabel =[[UILabel alloc] initWithFrame:CGRectMake(digX, digY, digW, digH)];
    
    [self.contentView addSubview:self.digestlabel];
    
    
    CGFloat timeX=220;
    CGFloat timeY =65;
    CGFloat timeW =150 ;
    CGFloat timeH =seH;
    
    self.ptime =[[UILabel alloc] initWithFrame:CGRectMake(timeX, timeY, timeW, timeH)];
    self.ptime.font =[UIFont systemFontOfSize:12];
    self.ptime.numberOfLines =0;
    self.ptime.textColor =[UIColor grayColor];
    [self.contentView addSubview:self.ptime];
    
    
    CGFloat imageX=5;
    CGFloat imageY=5;
    CGFloat imageW=120;
    CGFloat imageH=90;
    
    self.oneImageView =[[UIImageView alloc] initWithFrame:CGRectMake(imageX, imageY, imageW, imageH)];
    [self.contentView addSubview:self.oneImageView];
    
    
    
}
-(void)setModel:(NewModel *)model{
    if (_model !=model) {
        _model =nil;
        _model =model;
        [self layoutModel];
    }
}

-(void)layoutModel{
    self.titleLabel.text =self.model.title;
    self.digestlabel.text =self.model.digest;
    self.ptime.text =self.model.ptime;
    
    [self.oneImageView sd_setImageWithURL:[NSURL URLWithString:self.model.imgsrc]];
}













- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
